#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
typedef char BTDataType;

typedef struct BinaryTreeNode {
    BTDataType data;
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
} BTNode;

BTNode* BinaryTree(BTDataType* a, int* pi) {
    if (a[*pi] == '#')
    {
        (*pi)++;
        return NULL;
    }
    BTNode* root = (BTNode*)malloc(sizeof(BTNode));
    root->data = a[(*pi)++];
    root->left = BinaryTree(a, pi);
    root->left = BinaryTree(a, pi);
    return root;
}
void BinaryTreeInOrder(BTNode* root)
{
    if (root == NULL)
    {
        return;
    }
    BinaryTreeInOrder(root->left);
    printf("%c\n", root->data);
    BinaryTreeInOrder(root->right);
}

int main() {
    char arr[101] = { 0 };
    gets(arr);
    int i = 0;
    BTNode* root = BinaryTree(arr, &i);
    BinaryTreeInOrder(root);
    return 0;
}